package br.com.insight.consultoria.negocio.bo;

import java.util.List;

import br.com.insight.consultoria.entity.IntereceAtuacao;
import br.com.insight.consultoria.entity.Usuario;
import br.com.insight.consultoria.erro.exception.InsightConstants;
import br.com.insight.consultoria.erro.exception.InsightException;
import br.com.insight.consultoria.erro.exception.SistemaException;
import br.com.insight.consultoria.integracao.dao.interfacedao.IntereceAtuacaoDAO;
import br.com.insight.consultoria.negocio.bo.interfacebo.IntereceAtuacaoBO;

public class IntereceAtuacaoImpBO implements IntereceAtuacaoBO{

	private IntereceAtuacaoDAO intereceAtuacaoDAO;
	
	public void inserir(IntereceAtuacao intereceAtuacao)throws InsightException {
		
		try{
		
		getIntereceAtuacaoDAO().inserir(intereceAtuacao);
		
		}catch(InsightException exception){
			
			throw exception;
			
		}catch(Exception exception){
			
			throw new SistemaException(InsightConstants.MENSAGEM_ERRO_NAO_TRATADO,exception);
			
		}
		
	}
	
	public void alterar(IntereceAtuacao intereceAtuacao)throws InsightException {
		
		try{
		
		getIntereceAtuacaoDAO().alterar(intereceAtuacao);
		
		}catch(InsightException exception){
			
			throw exception;
			
		}catch(Exception exception){
			
			throw new SistemaException(InsightConstants.MENSAGEM_ERRO_NAO_TRATADO,exception);
			
		}
		
	}
	
	public void excluir(IntereceAtuacao intereceAtuacao)throws InsightException {
		
		try{
		
		getIntereceAtuacaoDAO().excluir(intereceAtuacao);
		
		}catch(InsightException exception){
			
			throw exception;
			
		}catch(Exception exception){
			
			throw new SistemaException(InsightConstants.MENSAGEM_ERRO_NAO_TRATADO,exception);
			
		}
		
	}
	
	public IntereceAtuacao getIntereceAtuacao(IntereceAtuacao.Id id)throws InsightException {
		
		try{
		
		return getIntereceAtuacaoDAO().getIntereceAtuacao(id);
		
		}catch(InsightException exception){
			
			throw exception;
			
		}catch(Exception exception){
			
			throw new SistemaException(InsightConstants.MENSAGEM_ERRO_NAO_TRATADO,exception);
			
		}
		
	}
	
	public List<IntereceAtuacao> pesquisar(Usuario usuario)throws InsightException {
		
		try{
		
		return getIntereceAtuacaoDAO().pesquisar(usuario);
		
		}catch(InsightException exception){
			
			throw exception;
			
		}catch(Exception exception){
			
			throw new SistemaException(InsightConstants.MENSAGEM_ERRO_NAO_TRATADO,exception);
			
		}
		
	}
	
	public boolean isCadastrado(IntereceAtuacao.Id id) throws InsightException{
		
		IntereceAtuacao atuacao=getIntereceAtuacao(id);
		
		if(atuacao!=null)
			return true;
		
			return false;
	}

	public IntereceAtuacaoDAO getIntereceAtuacaoDAO() {
		return intereceAtuacaoDAO;
	}

	public void setIntereceAtuacaoDAO(IntereceAtuacaoDAO intereceAtuacaoDAO) {
		this.intereceAtuacaoDAO = intereceAtuacaoDAO;
	}
	
	
	
}
